import { useCacheStore } from "@/stores";

export const useCache = ({ formatCacheData }: any = {}) => {
  const { cacheData, setData } = useCacheStore();
  onBeforeUnmount(() => {
    let data =
      typeof formatCacheData === "function"
        ? formatCacheData()
        : formatCacheData?.value || formatCacheData;
    setData({ ...data });
  });
  return { cacheData };
};
